<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Denzel - checkbox的应用</title>
    <meta name="description" content="前端笔记">
    <meta name="keywords" content="web前端,HTML5,CSS3,Javascript,SVG,canvas">
  <meta name="anthor" content="Denzel">
  <meta name="theme-color" content="#3eaf7c">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="msapplication-TileImage" content="/icons/msapplication-icon-144x144.png">
  <meta name="msapplication-TileColor" content="#000000">
  <link rel="icon" href="/blog/vuepress/logo.png">
  <link rel="manifest" href="/blog/vuepress/manifest.json">
  <link rel="apple-touch-icon" href="/blog/vuepress/icons/apple-touch-icon-152x152.png">
  <link rel="mask-icon" href="/blog/vuepress/icons/safari-pinned-tab.svg" color="#3eaf7c">
    
    <link rel="preload" href="/blog/vuepress/assets/css/0.styles.d4f29607.css" as="style"><link rel="preload" href="/blog/vuepress/assets/js/app.15770e34.js" as="script"><link rel="preload" href="/blog/vuepress/assets/js/47.11a8720a.js" as="script"><link rel="preload" href="/blog/vuepress/assets/js/65.923a8d15.js" as="script"><link rel="prefetch" href="/blog/vuepress/assets/js/46.59c0ece7.js"><link rel="prefetch" href="/blog/vuepress/assets/js/1.05e4270f.js"><link rel="prefetch" href="/blog/vuepress/assets/js/2.ace739f7.js"><link rel="prefetch" href="/blog/vuepress/assets/js/3.636e5a79.js"><link rel="prefetch" href="/blog/vuepress/assets/js/4.7a55aa4b.js"><link rel="prefetch" href="/blog/vuepress/assets/js/5.b56b0573.js"><link rel="prefetch" href="/blog/vuepress/assets/js/6.e9a3fbc8.js"><link rel="prefetch" href="/blog/vuepress/assets/js/7.aa46c47d.js"><link rel="prefetch" href="/blog/vuepress/assets/js/8.a9288ac6.js"><link rel="prefetch" href="/blog/vuepress/assets/js/9.b9f8dec6.js"><link rel="prefetch" href="/blog/vuepress/assets/js/10.3e2ea470.js"><link rel="prefetch" href="/blog/vuepress/assets/js/11.4d115f98.js"><link rel="prefetch" href="/blog/vuepress/assets/js/12.c97cf4d0.js"><link rel="prefetch" href="/blog/vuepress/assets/js/13.1e0cf594.js"><link rel="prefetch" href="/blog/vuepress/assets/js/14.bab9026a.js"><link rel="prefetch" href="/blog/vuepress/assets/js/15.1a24cffe.js"><link rel="prefetch" href="/blog/vuepress/assets/js/16.e9995850.js"><link rel="prefetch" href="/blog/vuepress/assets/js/17.86a1f7d2.js"><link rel="prefetch" href="/blog/vuepress/assets/js/18.c32400c4.js"><link rel="prefetch" href="/blog/vuepress/assets/js/19.9f99887c.js"><link rel="prefetch" href="/blog/vuepress/assets/js/20.82f0c2f9.js"><link rel="prefetch" href="/blog/vuepress/assets/js/21.7f5c223d.js"><link rel="prefetch" href="/blog/vuepress/assets/js/22.acf9934c.js"><link rel="prefetch" href="/blog/vuepress/assets/js/23.20d8e817.js"><link rel="prefetch" href="/blog/vuepress/assets/js/24.acf27379.js"><link rel="prefetch" href="/blog/vuepress/assets/js/25.20165510.js"><link rel="prefetch" href="/blog/vuepress/assets/js/26.83a2ddc3.js"><link rel="prefetch" href="/blog/vuepress/assets/js/27.33276a04.js"><link rel="prefetch" href="/blog/vuepress/assets/js/28.e320efab.js"><link rel="prefetch" href="/blog/vuepress/assets/js/29.3fd92c30.js"><link rel="prefetch" href="/blog/vuepress/assets/js/30.2bc84d43.js"><link rel="prefetch" href="/blog/vuepress/assets/js/31.d70ed500.js"><link rel="prefetch" href="/blog/vuepress/assets/js/32.e7a0f8e1.js"><link rel="prefetch" href="/blog/vuepress/assets/js/33.c48ee70b.js"><link rel="prefetch" href="/blog/vuepress/assets/js/34.8ad03d1b.js"><link rel="prefetch" href="/blog/vuepress/assets/js/35.5bdb3994.js"><link rel="prefetch" href="/blog/vuepress/assets/js/36.a25f926e.js"><link rel="prefetch" href="/blog/vuepress/assets/js/37.7515cfbb.js"><link rel="prefetch" href="/blog/vuepress/assets/js/38.99347371.js"><link rel="prefetch" href="/blog/vuepress/assets/js/39.3481fc62.js"><link rel="prefetch" href="/blog/vuepress/assets/js/40.bc709734.js"><link rel="prefetch" href="/blog/vuepress/assets/js/41.e1e0a3bf.js"><link rel="prefetch" href="/blog/vuepress/assets/js/42.762b61b0.js"><link rel="prefetch" href="/blog/vuepress/assets/js/43.8f0b2d6c.js"><link rel="prefetch" href="/blog/vuepress/assets/js/44.2a0a4ee0.js"><link rel="prefetch" href="/blog/vuepress/assets/js/45.baf7ed60.js"><link rel="prefetch" href="/blog/vuepress/assets/js/48.e0bf8b54.js"><link rel="prefetch" href="/blog/vuepress/assets/js/49.c96c4011.js"><link rel="prefetch" href="/blog/vuepress/assets/js/50.31189263.js"><link rel="prefetch" href="/blog/vuepress/assets/js/51.766a8294.js"><link rel="prefetch" href="/blog/vuepress/assets/js/52.26b971fd.js"><link rel="prefetch" href="/blog/vuepress/assets/js/53.0cfbd708.js"><link rel="prefetch" href="/blog/vuepress/assets/js/54.bdc15c87.js"><link rel="prefetch" href="/blog/vuepress/assets/js/55.fea285a9.js"><link rel="prefetch" href="/blog/vuepress/assets/js/56.e030a6b2.js"><link rel="prefetch" href="/blog/vuepress/assets/js/57.bd168a1e.js"><link rel="prefetch" href="/blog/vuepress/assets/js/58.636557fa.js"><link rel="prefetch" href="/blog/vuepress/assets/js/59.5d1d0ce6.js"><link rel="prefetch" href="/blog/vuepress/assets/js/60.0b779f92.js"><link rel="prefetch" href="/blog/vuepress/assets/js/61.4ec3f2eb.js"><link rel="prefetch" href="/blog/vuepress/assets/js/62.8f70f114.js"><link rel="prefetch" href="/blog/vuepress/assets/js/63.9ac2b61d.js"><link rel="prefetch" href="/blog/vuepress/assets/js/64.c028fad5.js"><link rel="prefetch" href="/blog/vuepress/assets/js/66.73db652e.js"><link rel="prefetch" href="/blog/vuepress/assets/js/67.1a91446d.js"><link rel="prefetch" href="/blog/vuepress/assets/js/68.e5a12a42.js"><link rel="prefetch" href="/blog/vuepress/assets/js/69.6ddcb882.js"><link rel="prefetch" href="/blog/vuepress/assets/js/70.ceb70d85.js"><link rel="prefetch" href="/blog/vuepress/assets/js/71.a804ef40.js"><link rel="prefetch" href="/blog/vuepress/assets/js/72.f1c4098c.js"><link rel="prefetch" href="/blog/vuepress/assets/js/73.2f28b842.js"><link rel="prefetch" href="/blog/vuepress/assets/js/74.571c2ab1.js"><link rel="prefetch" href="/blog/vuepress/assets/js/75.f365c2a1.js"><link rel="prefetch" href="/blog/vuepress/assets/js/76.0916a3cd.js"><link rel="prefetch" href="/blog/vuepress/assets/js/77.469aed17.js"><link rel="prefetch" href="/blog/vuepress/assets/js/78.02cdd59d.js"><link rel="prefetch" href="/blog/vuepress/assets/js/79.44d7f95c.js"><link rel="prefetch" href="/blog/vuepress/assets/js/80.4ca072f1.js"><link rel="prefetch" href="/blog/vuepress/assets/js/81.d9239a49.js"><link rel="prefetch" href="/blog/vuepress/assets/js/82.b09096b2.js"><link rel="prefetch" href="/blog/vuepress/assets/js/83.f4bc8a9b.js"><link rel="prefetch" href="/blog/vuepress/assets/js/84.1ffe6969.js"><link rel="prefetch" href="/blog/vuepress/assets/js/85.44e980f9.js"><link rel="prefetch" href="/blog/vuepress/assets/js/86.c8579ac0.js"><link rel="prefetch" href="/blog/vuepress/assets/js/87.cd49f324.js"><link rel="prefetch" href="/blog/vuepress/assets/js/88.3851b6ff.js"><link rel="prefetch" href="/blog/vuepress/assets/js/89.b05297be.js"><link rel="prefetch" href="/blog/vuepress/assets/js/90.c1e3263e.js"><link rel="prefetch" href="/blog/vuepress/assets/js/91.b493a1bb.js"><link rel="prefetch" href="/blog/vuepress/assets/js/92.80ab06fd.js"><link rel="prefetch" href="/blog/vuepress/assets/js/93.c6ca00b3.js"><link rel="prefetch" href="/blog/vuepress/assets/js/94.e993d310.js"><link rel="prefetch" href="/blog/vuepress/assets/js/95.8e19a7ed.js">
    <link rel="stylesheet" href="/blog/vuepress/assets/css/0.styles.d4f29607.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div><a href="/blog/vuepress/" class="home-link router-link-active"><img src="/blog/vuepress/hero.png" class="logo"><span class="site-name can-hide">
      Denzel
    </span></a><div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""><!----></div><nav class="nav-links can-hide"><div class="nav-item"><a href="/blog/vuepress/js/" class="nav-link">JS</a></div><div class="nav-item"><a href="/blog/vuepress/css/" class="nav-link router-link-active">CSS</a></div><div class="nav-item"><a href="/blog/vuepress/html/" class="nav-link">HTML</a></div><div class="nav-item"><a href="/blog/vuepress/else/" class="nav-link">其他</a></div><div class="nav-item"><a href="/blog/vuepress/study/" class="nav-link">study</a></div><a href="https://github.com/xiaotianxia" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header><div class="sidebar-mask"></div><div class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/blog/vuepress/js/" class="nav-link">JS</a></div><div class="nav-item"><a href="/blog/vuepress/css/" class="nav-link router-link-active">CSS</a></div><div class="nav-item"><a href="/blog/vuepress/html/" class="nav-link">HTML</a></div><div class="nav-item"><a href="/blog/vuepress/else/" class="nav-link">其他</a></div><div class="nav-item"><a href="/blog/vuepress/study/" class="nav-link">study</a></div><a href="https://github.com/xiaotianxia" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav><ul class="sidebar-links"><li><div class="sidebar-group first"><p class="sidebar-heading open"><span>CSS</span><!----></p><ul class="sidebar-group-items"><li><a href="/blog/vuepress/css/" class="sidebar-link">目录</a></li><li><a href="/blog/vuepress/css/svg_path_animation.html" class="sidebar-link">SVG轻松实现路径动画</a></li><li><a href="/blog/vuepress/css/clip_path.html" class="sidebar-link">CSS中的图像处理 —— clip-path</a></li><li><a href="/blog/vuepress/css/columns.html" class="sidebar-link">Columns —— CSS多栏布局</a></li><li><a href="/blog/vuepress/css/grid_layout.html" class="sidebar-link">Grid —— CSS网格布局初探</a></li><li><a href="/blog/vuepress/css/styled_switch.html" class="sidebar-link">radio和checkbox的自定义样式</a></li><li><a href="/blog/vuepress/css/use_of_checkbox.html" class="active sidebar-link">checkbox的应用</a></li></ul></div></li></ul></div><div class="page"><div class="content"><h1 id="checkbox的应用"><a href="#checkbox的应用" aria-hidden="true" class="header-anchor">#</a> checkbox的应用</h1><p><a href="https://denzel.netlify.com/css/use_of_checkbox.html" target="_blank" rel="noopener noreferrer">原文链接</a></p><h2 id="应用一-todo-list"><a href="#应用一-todo-list" aria-hidden="true" class="header-anchor">#</a> 应用一: todo list</h2><p>主要代码（LESS）：</p><pre class="language-css"><code><span class="token selector">input[type=checkbox]</span> <span class="token punctuation">{</span>
	<span class="token property">display</span><span class="token punctuation">:</span> none<span class="token selector">;
	
	&amp;:checked ~ span</span> <span class="token punctuation">{</span>
		<span class="token property">color</span><span class="token punctuation">:</span> <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
		
		<span class="token selector">&amp;:after</span> <span class="token punctuation">{</span>
			<span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">&amp;:checked ~ label</span> <span class="token punctuation">{</span>
		<span class="token selector">&amp;:after</span> <span class="token punctuation">{</span>
			<span class="token property">opacity</span><span class="token punctuation">:</span> 1<span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><p>demo截图
<img src="http://pn4meizzc.bkt.clouddn.com/blogchekbox001.gif" alt="demo截图"></p><p>或者看这里
<div class="codepen-wrapper"><a href="https://codepen.io/_tianxia/pen/NMJyMR" target="_blank" class="el-button el-button--primary is-plain">show in codepen <i class="el-icon-d-arrow-right"></i></a></div></p><h2 id="应用二-折叠菜单"><a href="#应用二-折叠菜单" aria-hidden="true" class="header-anchor">#</a> 应用二: 折叠菜单</h2><h3 id="非手风琴模式"><a href="#非手风琴模式" aria-hidden="true" class="header-anchor">#</a> 非手风琴模式</h3><p>因为checkbox是多选，可用来实现多页展开的折叠菜单</p><p>主要代码（LESS）：</p><pre class="language-css"><code><span class="token selector">.section</span> <span class="token punctuation">{</span>
	<span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token selector">;

	input[type=checkbox]</span> <span class="token punctuation">{</span>
		<span class="token property">display</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">label</span> <span class="token punctuation">{</span>
		<span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span>
		<span class="token property">cursor</span><span class="token punctuation">:</span> pointer<span class="token punctuation">;</span>
		<span class="token property">font-size</span><span class="token punctuation">:</span> 1.5em<span class="token punctuation">;</span>
		<span class="token property">line-height</span><span class="token punctuation">:</span> 2em<span class="token punctuation">;</span>
		<span class="token property">height</span><span class="token punctuation">:</span> 2em<span class="token punctuation">;</span>
		<span class="token property">box-shadow</span><span class="token punctuation">:</span> 1px 1px 1px 0 <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
		<span class="token selector">&amp;:hover</span> <span class="token punctuation">{</span>
			<span class="token property">background-color</span><span class="token punctuation">:</span> <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
			<span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">p</span> <span class="token punctuation">{</span>
		// <span class="token property">height</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
		<span class="token property">max-height</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
		<span class="token property">overflow</span><span class="token punctuation">:</span> hidden<span class="token punctuation">;</span>
		<span class="token property">padding</span><span class="token punctuation">:</span> 0 10px<span class="token punctuation">;</span>
		<span class="token property">line-height</span><span class="token punctuation">:</span> 20px<span class="token punctuation">;</span>
		<span class="token property">font-size</span><span class="token punctuation">:</span> 1em<span class="token punctuation">;</span>
		<span class="token property">transition</span><span class="token punctuation">:</span> max-height .3s linear<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">input[type=checkbox]:checked ~ p</span> <span class="token punctuation">{</span>
		// <span class="token property">height</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
		<span class="token property">max-height</span><span class="token punctuation">:</span>3000px<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">input[type=checkbox]:checked ~ label</span> <span class="token punctuation">{</span>
		<span class="token property">box-shadow</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
		<span class="token property">background-color</span><span class="token punctuation">:</span> <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
		<span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><p>demo截图
<img src="http://pn4meizzc.bkt.clouddn.com/chekbox002.gif" alt="demo截图"></p><p>或者看这里
<div class="codepen-wrapper"><a href="https://codepen.io/_tianxia/pen/ZoPMeE" target="_blank" class="el-button el-button--primary is-plain">show in codepen <i class="el-icon-d-arrow-right"></i></a></div></p><h3 id="手风琴模式"><a href="#手风琴模式" aria-hidden="true" class="header-anchor">#</a> 手风琴模式</h3><p>因为radio是单选，可用来实现手风琴模式的折叠菜单，只需要把上面的checkbox换成radio就可以了。</p><p>主要代码（LESS）：</p><pre class="language-css"><code><span class="token selector">.section</span> <span class="token punctuation">{</span>
	<span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token selector">;
	
	input[type=radio]</span> <span class="token punctuation">{</span>
		<span class="token property">display</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">label</span> <span class="token punctuation">{</span>
		<span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span>
		<span class="token property">cursor</span><span class="token punctuation">:</span> pointer<span class="token punctuation">;</span>
		<span class="token property">font-size</span><span class="token punctuation">:</span> 1.5em<span class="token punctuation">;</span>
		<span class="token property">line-height</span><span class="token punctuation">:</span> 2em<span class="token punctuation">;</span>
		<span class="token property">height</span><span class="token punctuation">:</span> 2em<span class="token punctuation">;</span>
		<span class="token property">box-shadow</span><span class="token punctuation">:</span> 1px 1px 1px 0 <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
		<span class="token selector">&amp;:hover</span> <span class="token punctuation">{</span>
			<span class="token property">background-color</span><span class="token punctuation">:</span> <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
			<span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">p</span> <span class="token punctuation">{</span>
		// <span class="token property">height</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
		<span class="token property">max-height</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
		<span class="token property">overflow</span><span class="token punctuation">:</span> hidden<span class="token punctuation">;</span>
    	<span class="token property">padding</span><span class="token punctuation">:</span> 0 10px<span class="token punctuation">;</span>
		<span class="token property">line-height</span><span class="token punctuation">:</span> 20px<span class="token punctuation">;</span>
		<span class="token property">font-size</span><span class="token punctuation">:</span> 1em<span class="token punctuation">;</span>
		<span class="token property">transition</span><span class="token punctuation">:</span> max-height .2s linear<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">input[type=radio]:checked ~ p</span> <span class="token punctuation">{</span>
		// <span class="token property">height</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
		<span class="token property">max-height</span><span class="token punctuation">:</span>3000px<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token selector">input[type=radio]:checked ~ label</span> <span class="token punctuation">{</span>
		<span class="token property">box-shadow</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
		<span class="token property">background-color</span><span class="token punctuation">:</span> <span class="token atrule"><span class="token rule">@color-gray</span><span class="token punctuation">;</span></span>
		<span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><p>demo截图
<img src="http://pn4meizzc.bkt.clouddn.com/chekbox003.gif" alt="demo截图"></p><p>或者看这里
<div class="codepen-wrapper"><a href="https://codepen.io/_tianxia/pen/vjPwmb" target="_blank" class="el-button el-button--primary is-plain">show in codepen <i class="el-icon-d-arrow-right"></i></a></div></p><div class="warning custom-block"><p class="custom-block-title">注意</p><p>做展开过渡效果时，一开始用的height: 0; -&gt;height: auto;搞半天搞不出动画效果。上网查得知css3貌似本来就有这么个“规定”：大概是只有固定值之间，才能使用插帧什么的手段实现过渡动画😄 。
但是可以用max-height实现：max-height: 0; -&gt; max-height: bigValue， 只要bigValue是一个大于最大auto高度的值就可以了。
当然，如果用先js计算出auto的高度再添加动画也是不错的方案，见张鑫旭老师的<a href="http://www.zhangxinxu.com/study/201501/css3-any-height-transition.html" target="_blank" rel="noopener noreferrer">文章</a>。</p></div></div><div class="wx-wrapper" data-v-0de8a4bf><p class="wx-txt" data-v-0de8a4bf>欢迎关注</p><img src="http://pn4meizzc.bkt.clouddn.com/wxqr.png" class="wx-img" data-v-0de8a4bf></div><div class="beg-wrapper" data-v-1f1af99c><a href="javascript:;" class="btn show" data-v-1f1af99c><img src="http://pn4meizzc.bkt.clouddn.com/blogshang_log.png" data-v-1f1af99c></a><p class="shang-txt" data-v-1f1af99c>赏不赏，看您心情</p><img src="http://pn4meizzc.bkt.clouddn.com/blogWechatIMG35.jpeg" class="shangImg" data-v-1f1af99c></div><!----><div class="content page-nav"><p class="inner"><span class="prev">
        ← <a href="/blog/vuepress/css/styled_switch.html" class="prev">
          radio和checkbox的自定义样式
        </a></span><!----></p></div></div></div></div>
    <script src="/blog/vuepress/assets/js/47.11a8720a.js" defer></script><script src="/blog/vuepress/assets/js/65.923a8d15.js" defer></script><script src="/blog/vuepress/assets/js/app.15770e34.js" defer></script>
  </body>
</html>
